import React from 'react'
import store from '../../store/index.js'
import Son from './son.js'
export default class Redu extends React.Component{
    constructor(){
        super()

        this.state={
            ...store.getState()
        }
    }
    componentDidMount(){
        store.subscribe(()=>{
            this.setState({
                ...store.getState()
            })
        })
    }
    render(){
        let {msg,num}=store.getState()
        return <div>
           <p>---------redux--共享数据</p>
           <div>
               <p>redux中的数据：：<span style={{color:'red'}}>{msg}</span></p>
               <p>修改后的变化：：<span style={{color:'#00f'}}>{num}</span></p>
           </div>
           <Son  store={store}></Son>
        </div>
    }
}